<template>
  <div>
    <Back />
    <div class="wk" v-for="item in list" :key="item.courseId">
      <img :src="url+item.imgUrl" alt="" />
      <dl>
        <dd>
          <h3>{{ item.courseName }}</h3>
        </dd>
        <dd>
          <span class="nopl">{{ item.courseType }}</span
          >|<span class="nopr">{{ item.courseLevel }}</span>
        </dd>
        <dd>{{ item.teacherName }}</dd>
      </dl>
      <i
        class="el-icon-s-opportunity"
        v-if="!item.attention"
        @click="() => follow(item)"
      ></i>
      <i
        class="el-icon-s-opportunity cc"
        v-if="item.attention"
        @click="() => nofollow(item)"
      ></i>
    </div>
  </div>
</template>

<script>
import { getSkills } from "../../../api/index";
import { delSkills } from "../../../api/index";
import { addSkills } from "../../../api/index";
export default {
  created() {  
    getSkills({
      userId: this.$store.state.id,
    }).then((res) => {
      this.list = res.data.data;
    });
  },
  data() {
    return {
      url:"http://192.168.10.32/cuihe/img/",
      id: 1,
      list: [],
    };
  },
  methods: {
    nofollow(item) {
      item.attention = false;
      delSkills({
        userId: this.id,
        dataId: item.courseId,
        a: 0,
      }).then((res) => {
      });
    },
    follow(item) {
      item.attention = true;
      addSkills({
        userId: this.id,
        dataId: item.courseId,
      }).then((res) => {
      });
    },
  },
};
</script>

<style scoped>
.wk img {
  width: 40vw;
  height: 20vw;
  margin-left: 3vw;
}
.wk {
  width: 100%;
  height: 25vw;
  margin-top: 7vw;
  padding-bottom: 2vw;
  display: flex;
  border-bottom: 00.3vw solid #ccc;
  align-items: center;
  justify-content: space-between;
}
.wk dl {
  margin-right: 5vw;
}
.wk h3 {
  color: black;
}
.wk dd {
  font-size: 3.5vw;
  color: #ccc;
}
.wk span {
  padding: 0 1vw;
}
.wk .nopl {
  padding-left: 0;
}
.wk .nopr {
  padding-right: 0;
}
.wk i {
  font-size: 7vw;
}
.wk .cc {
  color: cyan;
}
</style>